package com.service.impl;
import com.MybatisUtil.MybatisUtil;
import com.bean.Users;
import com.dao.UsersMapper;
import com.service.UsersService;
public class UsersServiceImpl implements UsersService {
    private  UsersMapper usersMapper;
    public UsersMapper getUsersMapper() {
        return usersMapper;
    }
    public void setUsersMapper(UsersMapper usersMapper) {
        this.usersMapper = usersMapper;
    }
    public  void updatepwd(int id, String newpwd , Users loginUsers ) {
        Users users =new Users();
        users.setId(id);
        users.setPwd(newpwd);
        usersMapper.updatePartial(users);
        //修改会话中的密码
        loginUsers.setPwd(newpwd);
        MybatisUtil.commit();
    }
    public Users login(String account, String pwd){
        Users user = usersMapper.findByName(account);
        if(user!=null && user.getPwd().equals(pwd)){
            System.out.println("TEST0");
            return user;
        }
        return null;
    }
    public void reg(Users user){
        usersMapper.add(user);
        MybatisUtil.commit();
    }
}
